package algotithm.weekendrace.biweeklycontest44.test1;/**
@author zhouyanxiang
@Date 2021-01-2021/1/23-20:20
*/
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] gain = {44,32,-9,52,23,-50,50,33,-84,47,-14,84,36,-62,37,81,-36,-85,-39,67,-63,64,-47,95,91,-40,65,67,92,-28,97,100,81};
        int res = solution.largestAltitude(gain);
        System.out.println();
        System.out.println(res);
    }

    public int largestAltitude(int[] gain) {
        int res = 0;
        int n = gain.length;
        int[] arr = new int[n+1];
        for (int i = 0; i < n; i++) {
            arr[i+1] = gain[i] + arr[i];
            res = Math.max(arr[i+1],res);
        }
        return res;
    }

}
